package com.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBLib {
	private static String DRIVER = "com.mysql.jdbc.Driver";
	private static String URL = "jdbc:mysql://localhost:3306/databaseweb";
	private static String USERNAME = "root";
	private static String PWD = "";
	
	public static Connection getConn(){
		Connection conn = null;
		try {
			//加载驱动
			Class.forName(DRIVER);
			//创建数据库连接
			conn = DriverManager.getConnection(URL, USERNAME, PWD);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return conn;
	}
	
	public static void main(String[] args) {
		System.out.println(getConn());
	}
}	
